package com.fortune.common.redis;


import com.fortune.constants.redis.CacheKeys;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.ValueOperations;

import java.util.concurrent.TimeUnit;

public class RedisClientImpl implements RedisClient {

	@Autowired
	private ValueOperations<String, String> valueOps;
	
	private String split = "_";
	
	@Override
	public void save(String value, long timeout, CacheKeys cacheKey, String prefix) {
		String key = cacheKey.name() + split + prefix;
		valueOps.set(key, value, timeout, TimeUnit.MINUTES);
	}

	@Override
	public String get(CacheKeys cacheKey, String prefix) {
		String key = cacheKey.name() + split + prefix;
		return valueOps.get(key);
	}

}
